package itu.dk.bosk.ex6_2;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Michael Valentin
 */
public class SumCell extends Cell {
    
    private Cell[] cells;
    
    public SumCell(Cell[] cells){
        this.cells = cells;
    }

    public SumCell(Cell c1, Cell c2){
        cells = new Cell[2];
        cells[0] = c1;
        cells[1] = c2;
    }

    @Override
    public double getNumberValue() {
        double sum = 0.0;
        for(Cell c : cells){
            sum += c.getNumberValue();
        }
        return sum;
    }

    public String toString() {
        return ""+getNumberValue();
    }
}
